﻿using K9Nano.Dependency;
using K9Nano.Session;

namespace K9Nano.Authorization;

public interface IRbacChecker
{
    bool Validate(string resource);
}


internal class RbacChecker(IUserContextAccessor userContextAccessor) : IRbacChecker, IScopedDependency
{
    public bool Validate(string resource)
    {
        var user = userContextAccessor.CurrentUser;
        if (user is null)
        {
            return false;
        }

        return user.HasPermission(resource);
    }
}
